<template>
  <div :id="self.name"
  style="position: relative;
          width: 100%;
          height: 90vh;
          margin: 0;
          padding: 0;"
  >
    
  </div>
</template>

<script>
import { ref, unref, watch } from 'vue'
import { init } from '/src/utils/base'
import { getSelection } from '/src/utils/index'
import { init as initBase } from './base'

import { post } from "/src/api/index";

export default {
    emits: ['baseMounted'],
    
    setup() {
        let self = {}

        initBase(self)
        
        init(self)

        const baseMounted = (v) => {
          self.onMounted(v);
        }
        

        let columns = [
          {
            name:'value',
            sortable: true,
          }
        ]

        self.amis.init({columns,
          insert_edit_actions:[
          ],
          insert_edit_bulk_actions: [
          ],
          append_header_actions: [
            {
              type: "button",
              level: "success",
              align: "right",
              label: "生成文件",
              confirmText: "确定要生成文件？",
              loadingOn: "${button_batch_create_file_loading}",
              onEvent: self.amis.onEventCreateFile,
            },
          ],
        })

        let schema = {
          ...self.amis.page_schema,
          body: [    
            {
              type: "crud",
              ...self.amis.commonSchema.crud,
              bulkActions: [
                {...self.amis.commonSchema.bulkActions.delete},
                {...self.amis.commonSchema.bulkActions.edit},
                {...self.amis.commonSchema.bulkActions.batchUpdateValue},
              ],
              filter: {
                title: '',
                persistData:unref(self.name)+'_filter',
                body: [
                  {...self.amis.commonSchema.filter.page_title},
                  {...self.amis.commonSchema.filter.workspace_name},
                  {
                    type: "input-text",
                    name: "name_like",
                    "clearable": true,
                    "placeholder": "请输入名称",
                    static: false,
                    width: 200,
                    size:'sm',
                  },
                  {
                    type: "input-text",
                    name: "value_like",
                    "clearable": true,
                    "placeholder": "请输入值",
                    static: false,
                    width: 200,
                    size:'sm',
                  },
                  {...self.amis.commonSchema.filter.search},
                ],
              },
            },
          ],
        }

        self.initAmis('#'+unref(self.name), schema)
        return {self:ref(self), baseMounted};
    },
};
</script>

